Skip to content

Fix auth failure when printing to authenticated CUPS policy#61

Merged
tillkamppeter merged 18 commits intoOpenPrinting:masterfrom
Souptik-De:master
Mar 23, 2026
Merged

Fix auth failure when printing to authenticated CUPS policy#61
tillkamppeter merged 18 commits intoOpenPrinting:masterfrom
Souptik-De:master

Conversation

@Souptik-De
Copy link
Copy Markdown

cupsCreateDestJob() was called with a manually managed http_t* from
cupsConnectDest(). This creates a TCP connection to the printer queue
where Local peer credential auth is impossible and Kerberos is
unavailable, causing a 401 Unauthorized when the CUPS policy requires
authentication.

Fix by using CUPS_HTTP_DEFAULT for all CUPS job I/O. This causes the
CUPS library to connect to cupsd via the Unix domain socket, where the
kernel automatically vouches for the caller's UID via peer credentials
(SO_PEERCRED), satisfying the authenticated policy without a password.

Also fix a thread safety bug:
cupsStartDestDocument was called on the
main thread but cupsWriteRequestData and cupsFinishDestDocument were
called on the worker thread using the same http_t*. Since
CUPS_HTTP_DEFAULT is per-thread (stored in _cups_globals_t), all three
calls must be on the same thread. Move cupsStartDestDocument and
cupsCopyDestInfo into the worker thread alongside the data transfer
calls.

…ket and add cupsFreeOptions and g_free for failure return paths
cupsCreateDestJob() was called with a manually managed http_t* from
cupsConnectDest(). This creates a TCP connection to the printer queue
where Local peer credential auth is impossible and Kerberos is
unavailable, causing a 401 Unauthorized when the CUPS policy requires
authentication.

Fix by using CUPS_HTTP_DEFAULT for all CUPS job I/O. This causes the
CUPS library to connect to cupsd via the Unix domain socket, where the
kernel automatically vouches for the caller's UID via peer credentials
(SO_PEERCRED), satisfying the authenticated policy without a password.

Also fix a thread safety bug: cupsStartDestDocument was called on the
main thread but cupsWriteRequestData and cupsFinishDestDocument were
called on the worker thread using the same http_t*. Since
CUPS_HTTP_DEFAULT is per-thread (stored in _cups_globals_t), all three
calls must be on the same thread. Move cupsStartDestDocument and
cupsCopyDestInfo into the worker thread alongside the data transfer
calls.
@Souptik-De Souptik-De marked this pull request as ready for review March 23, 2026 14:37
@tillkamppeter tillkamppeter merged commit 9a224c9 into OpenPrinting:master Mar 23, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants